<table id="dg-tzxx" style="height:100%;width: 100%;">
    <thead>
    <tr>
        <th field="ck" checkbox="true"></th>
        <th data-options="field:'GS_MC',width:100">公司名称</th>
        <th data-options="field:'GSB_MC',width:150">小公司名称</th>
        <th data-options="field:'RY_XM',width:100">员工姓名</th>
        <th data-options="field:'RY_ZJLX',width:100">证件类型</th>
        <th data-options="field:'RY_ZJHM',width:100">证件号码</th>
        <th data-options="field:'RY_LXFS',width:100">联系电话</th>
        <th data-options="field:'USER_XM',width:100">录入人</th>
        <th data-options="field:'TZJL_NR',width:150">调整福利</th>
        <th data-options="field:'TZJL_RQ',formatter:DateFormatter,width:100">调整日期</th>
    </tr>
    </thead>
</table>

<div id="tb-tzxx">
    <table cellpadding="0" cellspacing="0" style="width:100%">
        <tr class="clearfix">
            <td nowrap>公司名称:</td>
            <td nowrap><input class="easyui-textbox" name="dg_tzxx_gsmc" id="dg_tzxx_gsmc" style="width:120px"></td>
            <td nowrap>小公司名称:</td>
            <td nowrap><input class="easyui-textbox" name="dg_tzxx_xgsmc" id="dg_tzxx_xgsmc" style="width:120px"></td>
            <td nowrap>员工姓名:</td>
            <td nowrap><input class="easyui-textbox" name="dg_tzxx_xm" id="dg_tzxx_xm" style="width:120px"></td>
            <td nowrap>证件号码：</td>
            <td nowrap><input class="easyui-textbox" name="dg_tzxx_sfzhm" id="dg_tzxx_sfzhm" style="width:120px"></td>
            <td nowrap>查询月份起：</td>
            <td nowrap><input class="easyui-my97" name="dg_tzxx_cxyfq" id="dg_tzxx_cxyfq" data-options="dateFmt:'yyyyMM',maxDate:'#F{$dp.$D(\'dg_tzxx_cxyfz\')}'" style="width:80px"></td>
            <td nowrap>查询月份止：</td>
            <td><input class="easyui-my97" name="dg_tzxx_cxyfz" id="dg_tzxx_cxyfz" data-options="dateFmt:'yyyyMM',minDate:'#F{$dp.$D(\'dg_tzxx_cxyfq\')}'" style="width:80px"></td>
        </tr>
        <tr class="clearfix">
            <td class="luck-tool-button" colspan="12">
                <a href="#" class="easyui-linkbutton" iconCls="icon-search" onclick="tzxx_tool.search();">${i18n('btn.search')}</a>
                <a href="#" class="easyui-linkbutton button-blue" plain="true" onclick="tzxx_tool.add();"><i class="fa fa-plus fa-lg"></i>&nbsp;${i18n('btn.new')}</a>
                <a href="#" class="easyui-linkbutton button-warning" plain="true" onclick="tzxx_tool.edit();"><i class="fa fa-edit fa-lg"></i>&nbsp;${i18n('btn.edit')}</a>
                <a href="#" class="easyui-linkbutton button-red" plain="true" onclick="tzxx_tool.delete();"><i class="fa fa-close fa-lg"></i>&nbsp;${i18n('btn.delete')}</a>
                <a href="#" class="easyui-linkbutton button-info" plain="true" onclick="tzxx_tool.import();"><i class="fa fa-file-excel-o fa-lg"></i>&nbsp;${i18n('btn.import')}</a>
                <a href="#" class="easyui-linkbutton button-primary" plain="true" onclick="tzxx_tool.export();"><i class="fa fa-file-excel-o fa-lg"></i>&nbsp;${i18n('btn.export')}</a>
                <a href="#" class="easyui-linkbutton button-pink" plain="true" onclick="tzxx_tool.download();"><i class="fa fa-download fa-lg"></i>&nbsp;${i18n('btn.mb')}</a>
            </td>
        </tr>
    </table>
</div>
<script>
    var dg_tzxx;
    $(function () {
        dg_tzxx = rsdp.createDataGrid({
            tid: "dg-tzxx",
            url: "${ctxPath}/htxx/tzxx/manage",
            idField: "tzjl_id",
            loadMsg: "${i18n('oper.loading')}",
            tbid: "tb-tzxx",
            singleSelect: false
        });
    });

    var tzxx_tool = {
        add: function () {
            rsdp.createDialog({
                url: "${ctxPath}/htxx/tzxx/add",
                title: "${i18n('msg.tzxx.new')}",
                width: 500,
                height: 500,
                btnArray: [{
                    cls: 'easyui-linkbutton button-blue',
                    iconCls: 'fa fa-check fa-lg',
                    text: "${i18n('btn.save')}",
                    handler: function () {
                        tzxx_tool.add_save();
                    }
                },
                    {
                        iconCls: 'fa fa-close fa-lg',
                        text: "${i18n('btn.close')}",
                        handler: function () {
                            rsdp.closeDialog();
                        }
                    }]
            });
            //清除关闭数据没清空问题
            $("#form-add").form('clear');
        },
        add_save: function () {
            rsdp.ajaxform({
                fid: "form-add",
                url: "${ctxPath}/htxx/tzxx/addSave",
                func: function () {
                    rsdp.closeDialog();
                    dg_tzxx.datagrid("reload");
                    dg_tzxx.datagrid("clearChecked");
                }
            });
        },
        edit: function () {
            var rows = getCheckedRows('#dg-tzxx');

            if (rows.length == 1) {
                rsdp.createDialog({
                    url: "${ctxPath}/htxx/tzxx/edit",
                    title: "${i18n('msg.tzxx.edit')}",
                    width: 500,
                    height: 500,
                    param: {id: rows[0].TZJL_ID},
                    btnArray: [{
                        cls: 'easyui-linkbutton button-blue',
                        iconCls: 'fa fa-check fa-lg',
                        text: "${i18n('btn.save')}",
                        handler: function () {
                            tzxx_tool.edit_save();
                        }
                    },
                        {
                            iconCls: 'fa fa-close fa-lg',
                            text: "${i18n('btn.close')}",
                            handler: function () {
                                rsdp.closeDialog();
                            }
                        }]
                });
            }
            else {
                //layer.msg("${i18n('msg.row.select')}", {time: 1000});
                rsdp.msg("${i18n('msg.row.select')}", {time: 1000});
            }
        },
        edit_save: function () {
            rsdp.ajaxform({
                fid: "form-edit",
                url: "${ctxPath}/htxx/tzxx/editSave",
                func: function () {
                    rsdp.closeDialog();
                    dg_tzxx.datagrid("reload");
                    dg_tzxx.datagrid("clearChecked");
                }
            });
        },
        import: function () {
            rsdp.createDialog({
                url: "${ctxPath}/htxx/tzxx/import",
                title: "${i18n('msg.tzxx.import')}",
                width: 500,
                height: 200,
                btnArray: [{
                    cls: 'easyui-linkbutton button-blue',
                    iconCls: 'fa fa-check fa-lg',
                    text: "${i18n('btn.save')}",
                    handler: function () {
                        tzxx_tool.import_save();
                    }
                },
                    {
                        iconCls: 'fa fa-close fa-lg',
                        text: "${i18n('btn.close')}",
                        handler: function () {
                            rsdp.closeDialog();
                        }
                    }]
            });
        },
        import_save: function () {
            rsdp.ajaxUpload({
                fid: 'form-import',
                url: "${ctxPath}/htxx/tzxx/importSave",
                loading: "${i18n('oper.upload')}",
                success: function () {
                    rsdp.closeDialog();
                    dg_tzxx.datagrid("reload");
                    dg_tzxx.datagrid("clearChecked");
                }

            });
        },
        refresh: function () {
            rsdp.refresh();
        },
        search: function () {
            dg_tzxx.datagrid('load', {
                gsmc: $('#dg_tzxx_gsmc').val(),
                xgsmc: $('#dg_tzxx_xgsmc').val(),
                xm: $('#dg_tzxx_xm').val(),
                sfzhm: $('#dg_tzxx_sfzhm').val(),
                cxyfq: $('#dg_tzxx_cxyfq').my97('getValue'),
                cxyfz: $('#dg_tzxx_cxyfz').my97('getValue')
            });
            dg_tzxx.datagrid("clearChecked");
        },
        delete: function () {
            var rows = getCheckedRows('#dg-tzxx');
            //console.log(rows);
            //console.log(rows.length);
            if (rows.length > 0) {
                var strIds = "";
                //拼接字符串，这里也可以使用数组，作用一样
                for (var i = 0; i < rows.length; i++) {
                    strIds += rows[i].TZJL_ID + ",";
                }
                rsdp.ajaxPostJson({
                    url: "${ctxPath}/htxx/tzxx/delete",
                    param: {"id": strIds},
                    cstr: "${i18n('msg.tzxx.delete')}",
                    func: function () {
                        dg_tzxx.datagrid("reload");
                        dg_tzxx.datagrid("clearChecked");
                    }
                });
            }
            else {
                //layer.msg("${i18n('msg.row.selectm')}", {time: 1000});
                rsdp.msg("${i18n('msg.row.selectm')}", {time: 1000});
            }
        },
        export: function (obj) {
            var form = $("<form>");
            form.attr('style', 'display:none');
            form.attr('target', '');
            form.attr('method', 'post');
            form.attr('action', "${ctxPath}/htxx/tzxx/export");
            var input1 = $('<input>');
            input1.attr('type', 'hidden');
            input1.attr('name', 'gsmc');
            input1.attr('value', $('#dg_tzxx_gsmc').val());
            var input2 = $('<input>');
            input2.attr('type', 'hidden');
            input2.attr('name', 'xgsmc');
            input2.attr('value', $('#dg_tzxx_xgsmc').val());
            var input3 = $('<input>');
            input3.attr('type', 'hidden');
            input3.attr('name', 'xm');
            input3.attr('value', $('#dg_tzxx_xm').val());
            var input4 = $('<input>');
            input4.attr('type', 'hidden');
            input4.attr('name', 'sfzhm');
            input4.attr('value', $('#dg_tzxx_sfzhm').val());
            var input5 = $('<input>');
            input5.attr('type', 'hidden');
            input5.attr('name', 'cxyfq');
            input5.attr('value', $('#dg_tzxx_cxyfq').val());
            var input6 = $('<input>');
            input6.attr('type', 'hidden');
            input6.attr('name', 'cxyfz');
            input6.attr('value', $('#dg_tzxx_cxyfz').val());
            $('body').append(form);
            form.append(input1);
            form.append(input2);
            form.append(input3);
            form.append(input4);
            form.append(input5);
            form.append(input6);

            form.submit();
            form.remove();
        },
        download: function () {
            var form = $("<form>");
            form.attr('style', 'display:none');
            form.attr('target', '');
            form.attr('method', 'post');
            form.attr('action', "${ctxPath}/htxx/tzxx/download");
            $('body').append(form);
            form.submit();
            form.remove();
        }
    }
</script>